<?php
session_start();
require ("./core/conn.php");
if ($_POST) {
    if (get_magic_quotes_gpc()) {
        $reemail = htmlspecialchars(trim($_POST['email']));
        $edit = htmlspecialchars(trim($_POST['content']));
    } else {
        $reemail = htmlspecialchars(trim($_POST['email']));
        $edit = addslashes(htmlspecialchars(trim($_POST['content'])));
    }
    // 修改为空时，将修改时间置为空
    $edittime = $edit ? time() : 'NULL';
    $update_sql = "UPDATE msg SET email = '$reemail', content = '$edit', edittime = $edittime WHERE id = $_POST[id]";
    if (mysqli_query($conn, $update_sql)) {
        exit(htmlspecialchars_decode('ok'));
    } else {
        exit(htmlspecialchars_decode('修改失败'));
    }
}
?>